<?php
defined('_JEXEC') or die('Restricted access');
require_once( dirname(__FILE__).DS.'helper.php' );

if(	isset($params['id_content']) ||  isset($_GET['id']))
{
	if(isset($params['id_content']))
	{
		$id=$params['id_content'];
	}else{
		$id=mysql_real_escape_string($_GET['id']);
	}
	
	$content = contentHelper::getContent($id);
	
	$link_cat= BASE_URL.'/'.$content['cat_alias'].'.html';
	$brvalue[]=$content['cat_title'].'#$#'.$link_cat;
	$brvalue[]=$content['title'].'#$#';
	ComponentLibs::breadcrumbs($brvalue);

	$_SESSION['title']=$content['title'];
	$_SESSION['description']=$content['metadesc'];
	$_SESSION['keywords']=$content['metakey'];
	
	// Lay len tin tuc cung loai
	// Lay ID category
	$catid = contentHelper::getCatid($id);
	$start = 0;
	$number = 10;
	$ordering = 'id DESC';
	$where = "catid = $catid AND id <> $id";
	$content_other = contentHelper::getAllData($start, $number, $ordering, $where);
	
	include( dirname(__FILE__).DS.'tmpl'.DS.'detail'.DS.'default.php' );
}
else
{
	$number=5;
	if(isset($_GET['start'])){
		$start=$_GET['start'];
	}else{
		$start=0;
	}
	
	// $ordering
	//TODO: lay du lieu theo param ( secsion hay category)
	// $where='sectionid=2';
	// $where='catid=8';
	$where='';
	$data = contentHelper::getAllData($start,$number,'',$where);
	// echo "<pre>";
	// print_r($ComponentName);
	// echo "</pre>";
	//TODO: breadcrumb
	$brvalue[]=$ComponentName.'#$#';
	ComponentLibs::breadcrumbs($brvalue);
	
	
	$base_url ='?';
	$tongsodong=$data['number'];
	$soluongtrentrang=10;
	$pagintion = HamhaydungLibs::pagenav($base_url, $start, $tongsodong, $soluongtrentrang);
	
	include( dirname(__FILE__).DS.'tmpl'.DS.'list'.DS.'blog.php' );
}
?>
